<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script>
        function answer(){
            //根据id，得到指定id对应的元素对象
            var spanObj=document.getElementById("infoSpan");
        //    设置标签中间的文本
            spanObj.innerHTML="打瞌睡";
            //设置标签文本的颜色
            spanObj.style.color="red";
            spanObj.style.backgroundColor="yellow";
            spanObj.style.fontSize="12px";

        }
    </script>
</head>
<body>
    <input type="button" value="打什么不费力气？" onclick="answer();">
    <span id="infoSpan"></span>
</body>
</html>